import {lazy} from "react"
import {Navigate} from "react-router-dom"
const Login = lazy(()=>import("../views/Login"))
const Home = lazy(()=>import("../views/Home/Home"))
const Navlink1 = lazy(()=>import("../views/Home/Navlink1"))
const Navlink2 = lazy(()=>import("../views/Home/Navlink2"))
const Navlink3 = lazy(()=>import("../views/Home/Navlink3"))
const NotFind = lazy(()=>import("../views/notFind"))
const TestPaper = lazy(()=>import("../views/Home/testPaper"))
const TestPaper1 = lazy(()=>import("../views/Home/TsetPaper1"))
const TestPaper2 = lazy(()=>import("../views/Home/TestPaper2"))

export const userChildren = [ // 普通用户路由
    {
        path:"/home/navlink1",
        element:<Navlink1></Navlink1>,
        tit:"导航1"
    },
    {
        path:"/home/navlink2",
        element:<Navlink2></Navlink2>,
        tit:"导航2"
    },
    {
        path:"/home/navlink3",
        element:<Navlink3></Navlink3>,
        tit:"导航3"
    },
]
export const adminChildren = [ // 管理员的路由
    {
        path:"/home/navlink1",
        element:<Navlink1></Navlink1>,
        tit:"导航1"
    },
    {
        path:"/home/navlink2",
        element:<Navlink2></Navlink2>,
        tit:"导航2"
    },
    {
        path:"/home/navlink3",
        element:<Navlink3></Navlink3>,
        tit:"导航3"
    },
    {
        path:"/home/testpaper",
        element:<TestPaper></TestPaper>,
        tit:"试卷管理",
        children:[
            {
                path:"/home/testpaper/testpaper1",
                element:<TestPaper1></TestPaper1>,
                tit:"试卷管理1",
            },
            {
                path:"/home/testpaper/testpaper2",
                element:<TestPaper2></TestPaper2>,
                tit:"试卷管理2",
            },
        ]
    }



]
const routerconfig = [
    {
        path:"/login",
        element:<Login></Login>
    },
    {
        path:"/home",
        element:<Home></Home>,
        children:window.localStorage.getItem("user") === "admin" ? adminChildren : userChildren
    },
    {
        path:"/",
        element:<Navigate to="/login"></Navigate>
    },
    {
        path:"*",
        element:<NotFind></NotFind>
    }
]

export default routerconfig